package com.example.contact.viewmodel

import androidx.lifecycle.ViewModel
import com.example.contact.model.Contact
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class ContactViewModel @Inject constructor():ViewModel() {

    val groupedContacts : MutableMap<String, MutableList<Contact>> = mutableMapOf()

    init{
        Contact.contacts.map { contact ->
            val capital = contact.key[0].uppercase()
            if(groupedContacts.containsKey(capital)){
                groupedContacts[capital]!!.add(contact)
            }else{
                groupedContacts[capital] = mutableListOf(contact)
            }
        }
    }
}